/*************************************************
Author: byron
Date: 12/10/2012
Description:
Notes: 
*************************************************/

#ifndef __CActCfg_h__
#define __CActCfg_h__

#include "commclass.h"
#include "CTArray.h"
#include "CTSizeString.h"
#include "CTHashObjectMgr.h"

class MsgReqGMPlayer;
class MsgAnsGMPlayer;
class MsgActInfo;
class MsgTips;
class CActMgr;
class pb_cfg_act_pb_cfg_fight_for_box_unit;

//活动ID标识唯一活动 后端绑定ID策划不能随意改动ID值
enum ENUM_ACT_ID_MACRO_TAG
{
    ACT_ID_WORLD_BOSS = 101,      //世界BOSS活动ID
    ACT_ID_WEEKEND_SHOP = 102,    //魔晶商人
    ACT_ID_ENEMY_ATK_CITY = 103,  //怪物攻城战
    ACT_ID_AUCTION  = 104,        //拍卖会
    ACT_ID_GRAN_BOSS  = 105,      //格兰学院BOSS活动ID
    ACT_ID_SLEN_BOSS  = 106,      //斯林学院BOSS活动ID
    ACT_ID_RAVAN_BOSS  = 107,     //拉文学院BOSS活动ID
    ACT_ID_HUFF_BOSS  = 108,      //霍奇学院BOSS活动ID
    ACT_ID_MAGIC_DOOR = 109,      //魔界传送门
    ACT_ID_CLAN_BATTLE = 110,     //家族战i
    ACT_ID_CLAN_DICE = 113,       //幸运闯关
    ACT_ID_CLAN_TREE = 114,       //家族神树
    ACT_ID_CLAN_SKILL = 117,      //家族技能
    ACT_ID_CLAN_SHOP = 118,       //家族商店
    ACT_ID_MAGIC_CONTRIBUTE = 119,//星门充能
    ACT_ID_CLAN_DAIL   = 120,     //家族转盘
    ACT_ID_FIGHT_END   = 121,     //一战到底
    ACT_ID_ACA_CUP = 122,         //学院杯
    ACT_ID_NEW_SALES   = 123,     //开服特卖
    ACT_ID_MANOR_BATTLE   = 124,  //领地战
};

//依靠活动定时配置 做一些定时下发类的操作
enum ENUM_ACT_UPDATE_MACRO_TAG
{
    ACT_UPDATE_TIME_0_00 = 0,      //0点更新
    ACT_UPDATE_TIME_23_00 = (23 * 3600),     //23:00更新
};

//活动类型与活动ID不同 活动类型用于一类活动相关的状态的配置
enum ENUM_ACT_TYPE_MACRO_TAG
{
    ACT_TYPE_WORLD_BOSS = 1, //世界BOSS
    ACT_TYPE_MAGIC_DOOR = 2, //魔界传送门
    ACT_TYPE_GRAN_BOSS  = 3, //格兰学院BOSS
    ACT_TYPE_SLEN_BOSS  = 4, //斯林学院BOSS
    ACT_TYPE_RAVAN_BOSS = 5, //拉文学院BOSS
    ACT_TYPE_HUFF_BOSS  = 6, //霍奇学院BOSS
    ACT_TYPE_ENEMY_ATK_CITY  = 7, //怪物攻城战
    ACT_TYPE_AUCTION = 8, //拍卖会
    ACT_TYPE_ARENA = 9, //竞技场
    ACT_TYPE_CLAN_BATTLE = 10, //家族战
    ACT_TYPE_FIGHT_END = 11, //一战到底
    ACT_TYPE_ACADEMY_CUP = 12, //学院杯
    ACT_TYPE_MANOR_BATTLE = 13, //领地战
};

class CActSegTime
{
public:
    CActSegTime() 
    {
        Clear();
    }

    void Clear()
    {
        _iStart = 0;
        _iStop = 0;
    }

    virtual ~CActSegTime() 
    {
    }

public:
    int _iStart;
    int _iStop;
};

class CActTimer
{
public:
    enum ENM_ACT_TIMER_TYPE_TAG
    {
        ACT_TIMER_MAGIC_DOOR_CLOSE = 1, //星门活动到期结束
    };

    CActTimer()
    {
        Clear();
    }

    void Clear()
    {
        _iType = 0;
        _iDelTime = 0;
        _uiData = 0;
    }

    virtual ~CActTimer()
    {
    }

    int GetType() const {return _iType;}
    int GetDelTime() const {return _iDelTime;}
    unsigned int GetData() const {return _uiData;}

    void SetType(int iVal) {_iType = iVal;}
    void SetDelTime(int iVal) {_iDelTime = iVal;}
    void SetData(unsigned int uiVal) {_uiData = uiVal;}

private:
    int             _iType;
    int             _iDelTime;
    unsigned int    _uiData;
};

class CActCfgData
{
    friend class CActMgr;
public:
    enum ENUM_ACT_OBJ_STAT_TAG
    {
        ACT_OBJ_STAT_AUTO_CLOSE = 1,        //自然时间关闭
        ACT_OBJ_STAT_AUTO_OPEN = 2,         //自然时间开启
        ACT_OBJ_STAT_FORCE_CLOSE = 3,       //强制设置关闭
        ACT_OBJ_STAT_FORCE_OPEN = 4,        //强制设置开启
    };

    //用于前端显示的活动状态
    enum ENUM_ACT_OBJ_FRONT_STAT_TAG
    {
        ACT_OBJ_FRONT_STAT_BEFORE_OPEN      = 1,    //早于(还未开始)
        ACT_OBJ_FRONT_STAT_CLOSE_ALREADY    = 2,    //晚于(已经结束)
        ACT_OBJ_FRONT_STAT_RUNNING          = 3,    //满足(正在进行)

        ACT_OBJ_FRONT_STAT_NOT_ENTER        = 4,    //未报名
        ACT_OBJ_FRONT_STAT_HAS_ENTER        = 5,    //已报名
        ACT_OJB_FRONT_STAT_WAIT_FOR_OPEN    = 6,    //等待开启

        ACT_OBJ_FRONT_STAT_ACA_CUP_FIRST    = 7,    //学院杯淘汰赛
        ACT_OBJ_FRONT_STAT_ACA_CUP_SECOND_16   = 8,    //学院杯决赛16强
        ACT_OBJ_FRONT_STAT_ACA_CUP_SECOND_8   = 9,    //学院杯决赛8强
        ACT_OBJ_FRONT_STAT_ACA_CUP_SECOND_4   = 10,    //学院杯决赛4强
        ACT_OBJ_FRONT_STAT_ACA_CUP_SECOND_2   = 11,    //学院杯2强
        ACT_OBJ_FRONT_STAT_ACA_CUP_SECOND_1   = 12,    //学院杯决赛
    };

    enum ENUM_ACT_DATE_TIME_TAG
    {
        ACT_CFG_DATE_TIME = 1,      //日期时间格式 YYYY-mm-dd HH:MM:SS
        ACT_CFG_SEG_TIME = 2,       //段时间格式 HH:MM 或者 H:MM
        ACT_CFG_REL_OPEN = 3,       //开服的相对日期 @X   开服首日为@1, 第二天@2
    };

    CActCfgData() 
    {
        Clear();
    }

    void Clear()
    {
        _chStat = 0;
        _chType = 0;
        _bAllDayOpen = false;
        _shResID = 0;
        _shSceneID = 0;
        _iBeginTime = 0;
        _iEndTime = 0;
        _iStartTime = 0;
        _iStopTime = 0;
        _ucOpenDays = 0;
        _iUpdateTime = -1;//考虑0点时刻初始值为-1
        _iLastUpdate = 0;
        _iTipID = 0;
        _iLastTip = 0;

        _astSegTime.Clear();
    }

    virtual ~CActCfgData() 
    {
    }

    bool IsValidID() const {return _shResID > 0;}

    bool IsAutoClose() const {return ACT_OBJ_STAT_AUTO_CLOSE == _chStat;}
    bool IsForceClose() const {return ACT_OBJ_STAT_FORCE_CLOSE == _chStat;}
    bool IsAutoOpen() const {return ACT_OBJ_STAT_AUTO_OPEN == _chStat;}
    bool IsForceOpen() const {return ACT_OBJ_STAT_FORCE_OPEN == _chStat;}

    bool IsActOpen() const {return (IsAutoOpen()||IsForceOpen());}

    void SetForceClose(){_chStat = ACT_OBJ_STAT_FORCE_CLOSE;}
    void SetForceOpen(){_chStat = ACT_OBJ_STAT_FORCE_OPEN;}

    char GetType() const {return _chType;}
    bool IsAllDayOpen() const {return _bAllDayOpen;}
    short GetResID() const {return _shResID;}
    short GetSceneID() const {return _shSceneID;}
    unsigned char GetWeekOpenDays() const {return _ucOpenDays;}

    int GetBeginTime() const {return _iBeginTime;}
    int GetEndTime() const {return _iEndTime;}

    int GetStartTime() const {return _iStartTime;}
    int GetStopTime() const {return _iStopTime;}
    int GetUpdateTime() const {return _iUpdateTime;}
    int GetLastUpdate() const {return _iLastUpdate;}
    int GetTipID() const {return _iTipID;}
    int GetLastTip() const {return _iLastTip;}

    void SetStat(char chStat, int iBeginTime, int iEndTime);

    void GetActInfo(MsgActInfo& stActInfo);
    void GetActInfo(MsgActInfo& stActInfo, int iStatus);

    //设置\获取活动开启的星期
    bool IsWeekOpenDay (unsigned char ucDay) const 
    {
        ucDay = (0 == ucDay ? 7 : ucDay);  //星期天
        return (_ucOpenDays & (1 << ucDay));
    }

    int SetWeekOpenDay(unsigned char ucDay){return _ucOpenDays |= (1 << ucDay);}
    void SetAllWeekOpen(){_ucOpenDays = (unsigned char)0xFF;}

    void SetType(char chType){_chType = chType;}
    void SetAllDayOpen(bool bVal){_bAllDayOpen = bVal;}
    void SetResID(short shResID){_shResID = shResID;}
    void SetSceneID(short shSceneID){_shSceneID = shSceneID;}
    void SetUpdateTime(int iVal){_iUpdateTime = iVal;}
    void SetLastUpdate(int iVal){_iLastUpdate = iVal;}
    void SetTipID(int iVal){_iTipID = iVal;}
    void SetLastTip(int iVal){_iLastTip = iVal;}
    void SetStartTime(int iStartTime)
    {
        _iStartTime = iStartTime;
        _iBeginTime = iStartTime;
    }
    void SetStopTime(int iStopTime)
    {
        _iStopTime = iStopTime;
        _iEndTime = iStopTime;
    }

    bool AddSegTime(CActSegTime& stSegTime)
    {
        if (_astSegTime.Size() < _astSegTime.GetCount())
        {
            if (_astSegTime.AddOneItem(stSegTime) >= 0)
            {
                return true;
            }
        }

        return false;
    }

    int GetSegBeginTime(int iSegId)
    {
        if (iSegId > _astSegTime.Size() || iSegId <= 0 )
        {
            return 0;
        }

        return _astSegTime[iSegId - 1]._iStart;
    }

    int GetSegEndTime(int iSegId)
    {
        if (iSegId > _astSegTime.Size() || iSegId <= 0 )
        {
            return 0;
        }

        return _astSegTime[iSegId - 1]._iStop;
    }

    bool IsValidSegTime();

    void RefreshAct();

    int GMDealAct(MsgReqGMPlayer& stReq, MsgAnsGMPlayer& stAns, bool bActOpen,
            CTSizeString<MAX_BATTLE_NAME_BUFF>& szNameStr);

private:
    //状态 活动配置和活动实例放在同一Hash统一管理
    char                _chStat;

    char                _chType;            //类型
    bool                _bAllDayOpen;       //是否全天开启
    short               _shResID;           //配置ID
    short               _shSceneID;         //场景配置ID

    //活动状态紧密相关的配置时间段的开始时间 活动配置和活动实例放在同一Hash统一管理
    int                 _iBeginTime;

    //活动状态紧密相关的配置时间段的结束时间 活动配置和活动实例放在同一Hash统一管理
    int                 _iEndTime;

    int                 _iStartTime;        //活动配置的起始时间
    int                 _iStopTime;         //活动配置的截止时间

    unsigned char       _ucOpenDays;        //出现的日期
    int                 _iUpdateTime;       //每日更新时刻
    int                 _iLastUpdate;       //上次更新时刻
    int                 _iTipID;            //活动开启提示ID
    int                 _iLastTip;          //上次提示时刻

    //活动配置的时间段
    CTLib::CTArray<CActSegTime, MAX_ACT_SEGMENT_COUNT> _astSegTime;
};

class CActCfg
{
    friend class CActMgr;
public:
    typedef CTLib::CTHashObjectMgr<short, CActCfgData> T_ACT_CFG_HASH;

    CActCfg() 
    {
    }

    virtual ~CActCfg() 
    {
    }

    static int CountSize()
    {
        return T_ACT_CFG_HASH::CountSize(MAX_ACT_CONFIG_COUNT);
    }

    int Init(const char* sBuff)
    {
        return _stActCfgHash.Init(sBuff, MAX_ACT_CONFIG_COUNT);
    }

    int AddConfig(CActCfgData& stCfgData);

    int FindConfig(short shResID);

    CActCfgData& GetConfig(int iIndex);

    void RefreshAct();

    int GMDealAct(MsgReqGMPlayer& stReq, MsgAnsGMPlayer& stAns);

    void GetActList(MsgTips& stTips);

private:
    T_ACT_CFG_HASH _stActCfgHash;
};

//精彩活动配置数据
class CSplendidActConfigData
{
public:
    CSplendidActConfigData()
    {

    }

public:
    bool _bHasConfig;

    int _iActID;        //活动ID
    int _iBeginTime;    //开始时间
    int _iEndTime;      //结束时间
    bool _bHasChildAct; //是否有后续活动
    int _iParentActID;  //前置活动ID
    bool _bIsSplendidAct;   //如果为false，则不在精彩活动列表显示
    CTLib::CTSizeString<1024> _szTargets;   //目标（原始数据）
    CTLib::CTSizeString<1024> _szBonus;     //奖励（原始数据）
};

class CSplendidActConfig
{
public:
    CSplendidActConfig()
    {

    }

    int AddConfig(CSplendidActConfigData& stConfigData)
    {
        if (stConfigData._iActID <= 0 || stConfigData._iActID > MAX_SPLENDID_ACT_COUNT
            || _astSplendidActConfigDatas[stConfigData._iActID]._bHasConfig)
        {
            CT_ERROR(("%d", stConfigData._iActID));
            return RET_SYS_ERROR;
        }

        if (stConfigData._iEndTime <= stConfigData._iBeginTime)
        {
            CT_ERROR(("%d, %d, %d", stConfigData._iActID, stConfigData._iEndTime, stConfigData._iBeginTime));
            return RET_SYS_ERROR;
        }

        _astSplendidActConfigDatas[stConfigData._iActID] = stConfigData;
        _astSplendidActConfigDatas[stConfigData._iActID]._bHasConfig = true;

        return 0;
    }

    int GetConfig(int iActID, CSplendidActConfigData& stConfigData)
    {
        stConfigData._iActID = iActID;
        if (stConfigData._iActID <= 0 || stConfigData._iActID > MAX_SPLENDID_ACT_COUNT
            || !_astSplendidActConfigDatas[stConfigData._iActID]._bHasConfig)
        {
            CT_ERROR(("%d", stConfigData._iActID));
            return RET_SYS_ERROR;
        }
        
        stConfigData = _astSplendidActConfigDatas[stConfigData._iActID];
        return 0;
    }

public:
    CTLib::CTArray<CSplendidActConfigData, MAX_SPLENDID_ACT_COUNT + 1> _astSplendidActConfigDatas;
};

//精彩活动详细配置
class CSplendidActConfigDetail
{
public:
    CSplendidActConfigDetail()
    {
        _iRedPacketGatherStart = 0;
        _iRedPacketGatherStop = 0;
    }

public:
    typedef CTLib::CTArray<int, MAX_SPLENDID_GQ_GET_CARD_COUNT> T_GQ_GET_CARD_TARGET; 

    CTLib::CTArray<short, MAX_SPLENDID_CRYCOMBINE_LEVEL_COUNT> _astCryCombineLevels;    //魔晶合成赢幸运活动等级配置
    CTLib::CTArray<int, MAX_SPLENDID_CRYCOMBINE_LEVEL_COUNT> _astCryCombineBonus;       //魔晶合成赢幸运奖励配置

    int _iClanRankCount;            //全服家族排名活动排名个数
    CTLib::CTArray<int, MAX_SPLENDID_CLAN_RANK_COUNT> _astClanMasterBonus;          //家族族长奖励
    CTLib::CTArray<int, MAX_SPLENDID_CLAN_RANK_COUNT> _astClanMemberBonus;          //家族成员奖励

    CTLib::CTArray<short, MAX_SPLENDID_EAC_TARGETS_COUNT> _astEacTargets;           //怪物攻城连杀奖励详细目标
    CTLib::CTArray<int, MAX_SPLENDID_EAC_TARGETS_COUNT> _astEacBonus;               //怪物攻城连杀奖励奖励

    CTLib::CTArray<int, MAX_BUY_GOLD_CONFIG_COUNT> _astBuyGoldConfigID;             //充值送魔晶活动,金币购买配置ID，只有这些ID才会送礼包
    CTLib::CTArray<int, MAX_BUY_GOLD_CONFIG_COUNT> _astBuyGoldGBonus;               //充值送魔晶活动奖励

    CTLib::CTArray<int, MAX_SPLENDID_ZQ_GIFT_COUNT> _astZQGiftBeginTime;            //中秋活动各礼包开始领取时间
    CTLib::CTArray<int, MAX_SPLENDID_ZQ_GIFT_COUNT> _astZQGiftID;                   //中秋活动礼包ID

    CTLib::CTArray<int, MAX_SPLENDID_PAY_RANK_COUNT> _astPayRankBonusTarget;        //消费排名奖励目标
    CTLib::CTArray<int, MAX_SPLENDID_PAY_RANK_COUNT> _astPayRankGift;               //消费排名奖励礼包

    int _iGQLoginBeginTime;                                                         //国庆登录开始时间 1号0点
    CTLib::CTArray<int, MAX_SPLENDID_GQ_LOGIN_DAYS> _astGQLoginGift;                //国庆登录奖励

    CTLib::CTArray<int, MAX_SPLENDID_GQ_GET_CARD_BONUS_COUNT> _astGQGetCardGift;                        //国庆集卡奖励
    CTLib::CTArray<T_GQ_GET_CARD_TARGET, MAX_SPLENDID_GQ_GET_CARD_BONUS_COUNT> _astGQGetCardTargets;    //国庆集卡目标

    //感恩节活动 
    int _iGanEnSendHammerByGold;                                                    //充值多少符石送锤子                                            
    int _iGanEnSendGiftByGold;                                                      //礼包分割线
    int _iGanEnSendMountByGold;                                                     //送坐骑额度
    int _iGanEnSendCryGiftByGold;                                                   //魔晶礼包额度
    int _iGanEnGiftID1;                                                             //低级礼包
    int _iGanEnGiftID2;                                                             //高级礼包
    int _iGanEnGiftID3;                                                             //高级有大奖礼包
    int _iGanEnGiftID4;                                                             //坐骑
    int _iGanEnGiftID5;                                                             //魔晶礼包
    int _iGanEnGiftID6;                                                             //金魂罐子

    //转盘        
    CTLib::CTArray<int, 6> _astZPGift1;
    CTLib::CTArray<int, 8> _astZPGift2;
    CTLib::CTArray<int, 8> _astZPGift3;

    //双蛋活动
    CTLib::CTArray<int, 4> _astSDGift1;
    CTLib::CTArray<int, 4> _astSDGift2;

    //摇摇乐活动
    int _iRockGold;
    CTLib::CTArray<int, MAX_SPLENDID_ROCK_NUM_COUNT> _aiRockRandomInt;
    CTLib::CTArray<int, MAX_SPLENDID_ROCK_RANDOM_GIFT> _aiRockRandomGift; //0 小奖包(普通组合) 1 大奖包A(图片相同且没得大奖) 2 大奖包B(图片相同且已得大奖)
    CTLib::CTArray<int, MAX_SPLENDID_ROCK_EXCHANGE_GIFT> _aiRockExchangeGift;
    CTLib::CTArray<int, MAX_SPLENDID_ROCK_EXCHANGE_GIFT> _aiRockExchangeMask;
    CTLib::CTArray<int, MAX_SPLENDID_ROCK_EXCHANGE_GIFT> _aiRockExchangeScore;

    //领红包活动
    int _iRedPacketGatherStart;
    int _iRedPacketGatherStop;
};

//活动状态配置
class CActStatusCfgData
{
public:
    CActStatusCfgData() 
    {
        Clear();
    }

    void Clear()
    {
        _shActID = 0;
        _iMerlinID = 0;
        _iInspireID = 0;
        _iDeadID = 0;
        _iCoolingID = 0;
    }

    virtual ~CActStatusCfgData() 
    {
    }

    bool IsValidID() const {return _shActID > 0;}

    short GetActID() const {return _shActID;}
    int GetMerlinID() const {return _iMerlinID;}
    int GetInspireID() const {return _iInspireID;}
    int GetDeadID() const {return _iDeadID;}
    int GetCoolingID() const {return _iCoolingID;}

    void SetActID(short shActID){_shActID = shActID;}
    void SetMerlinID(int iMerlinID){_iMerlinID = iMerlinID;}
    void SetInspireID(int iInspireID){_iInspireID = iInspireID;}
    void SetDeadID(int iDeadID){_iDeadID = iDeadID;}
    void SetCoolingID(int iCoolingID){_iCoolingID = iCoolingID;}

private:
    short           _shActID;       //活动配置ID
    int             _iMerlinID;     //梅林祝福ID
    int             _iInspireID;    //鼓舞士气ID
    int             _iDeadID;       //死亡状态ID
    int             _iCoolingID;    //战斗冷却ID
};

class CActStatusCfg
{
public:
    typedef
        CTLib::CTHashObjectMgr<short, CActStatusCfgData> T_ACT_STATUS_CFG_HASH;

    CActStatusCfg() 
    {
    }

    virtual ~CActStatusCfg() 
    {
    }

    static int CountSize()
    {
        return T_ACT_STATUS_CFG_HASH::CountSize(MAX_ACT_STATUS_CFG_COUNT);
    }

    int Init(const char* sBuff)
    {
        return _stActStatusCfgHash.Init(sBuff, MAX_ACT_STATUS_CFG_COUNT);
    }

    int AddConfig(CActStatusCfgData& stCfgData);

    int FindConfig(short shActID);

    CActStatusCfgData& GetConfig(int iIndex);

private:
    T_ACT_STATUS_CFG_HASH _stActStatusCfgHash;
};

//家族战奖励配置
class CClanBattleBonusConfigData
{
public:
    CClanBattleBonusConfigData()
        :_bHasConfig(false)
    {

    }

public:
    bool _bHasConfig;

    int _iRank;
    int _iRoleRankGiftID;  //个人排行榜奖励
    int _iClanRankGiftID;   //家族排行榜奖励
};

class CClanBattleBonusConfig
{
public:
    CClanBattleBonusConfig()
    {

    }

    int AddConfig(CClanBattleBonusConfigData& stConfigData)
    {
        if (stConfigData._iRank <= 0 || stConfigData._iRank >= _astBonusConfigDatas.GetCount()
            || _astBonusConfigDatas[stConfigData._iRank]._bHasConfig)
        {
            CT_ERROR(("%d", stConfigData._iRank));
            return RET_SYS_ERROR;
        }

        _astBonusConfigDatas[stConfigData._iRank] = stConfigData;
        _astBonusConfigDatas[stConfigData._iRank]._bHasConfig = true;
        return 0;
    }

    int GetConfig(int iRank, CClanBattleBonusConfigData& stConfigData)
    {
        stConfigData._iRank = iRank;

        if (stConfigData._iRank <= 0 || stConfigData._iRank >= _astBonusConfigDatas.GetCount()
            || !_astBonusConfigDatas[stConfigData._iRank]._bHasConfig)
        {
            CT_ERROR(("%d", stConfigData._iRank));
            return RET_SYS_ERROR;
        }

        stConfigData = _astBonusConfigDatas[stConfigData._iRank];

        return 0;
    }

public:
    CTArray<CClanBattleBonusConfigData, 20> _astBonusConfigDatas;
};

//宝箱争夺战
class CFightForBoxBonusConfig   //宝箱奖励配置
{
public:
    CFightForBoxBonusConfig()
    {
        _iID = 0;
        _iNeedPoint = 0;
        _uiTips = 0;
        _stDropItemData.Clear();
    }

    int _iID;           //奖励ID
    int _iNeedPoint;    //需要积分
    unsigned int _uiTips;     //兑换时触发跑马灯消息
    CDropItemData   _stDropItemData; //奖励的物品
};

class CFightForBoxRankBonusConfig   //排名的精力奖励配置
{
public:
    CFightForBoxRankBonusConfig()
    {
        _iRank = 0;
        _iBonusEnergy = 0;
    }

    int _iRank;             //排名
    int _iBonusEnergy;      //奖励的精力
};

class CFightForBoxConfig
{
public:
    enum
    {
        BOX_TYPE_NULL = 0, //已打开的箱子
        BOX_TYPE_1 = 1, //积分100
        BOX_TYPE_2 = 2, //积分50
        BOX_TYPE_3 = 3, //积分10
        BOX_TYPE_4 = 4, //眩晕2回合
        BOX_TYPE_5 = 5, //当前积分乘以2
        
        BOX_TYPE1_POINT = 100, 
        BOX_TYPE2_POINT = 50, 
        BOX_TYPE3_POINT = 10, 

        BOX_TYPE_MIN = 1,
        BOX_TYPE_MAX = 5,
    };  

    CFightForBoxConfig()
    {
        _iCanBuyEyeCount = 0;
        _iEyePrice = 0;
        _iOnePointToSilver = 0;
    }

    int AddConfig(const pb_cfg_act_pb_cfg_fight_for_box_unit& stConfigUnit);

    CTArray<unsigned char, MAX_FIGHT_FOR_BOX_BOX_COUNT> _aucBoxTypeTemplate;  //盒子模板, 用于做随机
    CTArray<int, MAX_FIGHT_FOR_BOX_NPC_COUNT> _aiAllNPC;                      //所有可能的NPC
    CTArray<CFightForBoxBonusConfig, MAX_FIGHT_FOR_BOX_BONUS_COUNT> _astExchangeBonus; //可兑换物品
    CTArray<CFightForBoxRankBonusConfig, MAX_FIGHT_FOR_BOX_ROLE_COUNT> _astRankBonus;  //排名奖励

    int _iCanBuyEyeCount;       //可购买慧眼次数
    int _iEyePrice;             //慧眼价格
    
    int _iOnePointToSilver;     //1积分可兑换的银币数
};

class CFightEndCfgData
{
public:
    CFightEndCfgData() 
    {
        Clear();
    }

    void Clear()
    {
        _iLevel = 0;
        _astDropItem.Clear();
    }

    virtual ~CFightEndCfgData() 
    {
    }

    bool IsValidLevel() {return (_iLevel > 0 && _iLevel < MAX_ROLE_LEVEL);}

    int GetLevel() const {return _iLevel;}
    int GetDropItemSize() const {return _astDropItem.Size();}
    CDropItemData& GetDropItem(int iIndex) {return _astDropItem[iIndex];}

    void SetLevel(int iVal) {_iLevel = iVal;}
    void AddDropItem(unsigned char ucType, unsigned short usID, int iCount)
    {
        CDropItemData stData;
        stData.Clear();

        stData._ucItemType = ucType;
        stData._usItemConfigID = usID;
        stData._iItemCount = iCount;

        _astDropItem.AddOneItem(stData);
    }

private:
    int         _iLevel;
    CTLib::CTArray<CDropItemData, MAX_FIGHT_END_AWARD_COUNT> _astDropItem;
};

class CFightEndConfig
{
public:
    CFightEndConfig() 
    {
        Clear();
    }

    void Clear()
    {
        _astConfig.Clear();
    }

    virtual ~CFightEndConfig() 
    {
    }

    int AddLevelConfig(CFightEndCfgData& stCfgData);

    int FindLevelConfig(int iLevel);

    CFightEndCfgData& GetLevelConfig(int iIndex);

private:
    CTLib::CTArray<CFightEndCfgData, MAX_FIGHT_END_CONFIG_COUNT> _astConfig;
};

class CNewZoneSalesItem
{
public:
    CNewZoneSalesItem()
    {
        _stItem.Clear();
        _iInitCost = 0;
        _iRealCost = 0;
    }
        
    CDropItemData _stItem;
    int _iInitCost;
    int _iRealCost;
};

class CNewZoneSalesConfig
{
public:
    CNewZoneSalesConfig() 
    {
        Clear();
    }

    void Clear()
    {
        _astConfig.Clear();
        _stBonus.Clear();
    }

    int AddItemConfig(CNewZoneSalesItem& stCfgData);

    int GetItemConfig (int iPos, CNewZoneSalesItem & stItem);

    CDropItemData _stBonus;
    CTLib::CTArray<CNewZoneSalesItem, NEWZONE_SALES_ITEM_CNT> _astConfig;
};

#endif // __CActCfg_h__

